package com.ds.dalgen.generator;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ds.dalgen.context.Context;
import com.ds.dalgen.generator.domain.GeneratorInfo;
import com.ds.dalgen.utils.VelocityUtils;

public class SpringDAOGenerator implements Generator {

	private static final String templateFile = "/daoimpl/springDao.vm";
	private static final String suffix = ".java";

	@Override
	public void generator(Context context) {
		// TODO Auto-generated method stub
		List<GeneratorInfo> generatorInfos = context.getGeneratorInfos();

		for (GeneratorInfo generatorInfo : generatorInfos) {
			String targetPackage = generatorInfo.getTargetPackage();
			String targetProject = generatorInfo.getTargetProject();
			String tableName = generatorInfo.getTableName();
			String tableAlias = generatorInfo.getTableAlias();

			Map<String, Object> params = new HashMap<String, Object>();
			params.put("targetPackage", targetPackage);
			params.put("targetProject", targetProject);

			VelocityUtils.generatorFiles(params, templateFile, targetProject, suffix);
		}
	}

}
